﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace 组合框控件
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            comboBox1.Items.Clear();
            comboBox2.Items.Clear();
            listBox1.Items.Clear();
           
            comboBox1.Items.Add("软件部");
            comboBox1.Items.Add("硬件部");
            comboBox1.Items.Add("财务部");
            comboBox1.Items.Add("人事部");
            comboBox1.SelectedIndex = 0;

            comboBox2.Items.Add("软件部");
            comboBox2.Items.Add("硬件部");
            comboBox2.Items.Add("财务部");
            comboBox2.Items.Add("人事部");
            comboBox2.SelectedIndex = 0;
            listBox1.Items.Add("软件部");
            listBox1.Items.Add("硬件部");
            listBox1.Items.Add("财务部");
            listBox1.Items.Add("人事部");
            listBox1.SelectedIndex = 0;

            textBox1.Text = "软件部";
        }

        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            string mess=comboBox1.SelectedItem.ToString();
            comboBox2.SelectedItem = mess;
            listBox1.SelectedItem = mess;

            textBox1.Text = mess;

        }
    }
}
